package online_exams.mapper;

import online_exams.domain.TUserEntity;
import online_exams.utils.Result;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdminMapper {
//根据用户名查询用户
    @Select( "select * from t_user where id_number=#{idNumber}")
    TUserEntity getUser(TUserEntity tUserEntity);

    @Insert("insert into t_user (role,id_number,real_name,email,phone,password) values (#{role},#{idNumber},#{realName},#{email},#{phone},#{password})")
    Integer addUser(TUserEntity tUserEntity);

    int selectTotal(@Param("tUserEntity") TUserEntity tUserEntity);

    List<TUserEntity> selectPage(@Param("tUserEntity") TUserEntity tUserEntity,
                                 @Param("offset") int offset,
                                 @Param("pageSize") int pageSize);

    @Update("update t_user set password=#{password} where id_number=#{idNumber}")
    Integer updatePassword(TUserEntity tUserEntity);

    @Update("update t_user set role=#{role},real_name=#{realName},email=#{email},phone=#{phone} where id_number=#{idNumber}")
    Integer updateUser(TUserEntity tUserEntity);
}
